﻿using System;
using System.Collections.Generic;

namespace TestExtensions.Reporting
{
    public static class ReportRendererFactory
    {
        private static Dictionary<RenderTarget, IReportRenderer> _renderers;

        static ReportRendererFactory()
        {
            _renderers = new Dictionary<RenderTarget, IReportRenderer>();
        }

        public static IReportRenderer GetRenderer(RenderTarget target)
        {
            if (!_renderers.ContainsKey(target))
            {
                switch (target)
                {
                    case RenderTarget.Console:
                        _renderers[target] = new ConsoleReportRenderer();
                        break;
                    default:
                        throw new NotImplementedException(string.Format("Report target type '{0}' has not been defined.", target));
                }
            }
            return _renderers[target];
        }
    }
}